/*
 * @Author: szx
 * @Date: 2021-12-06 14:03:53
 * @LastEditTime: 2021-12-06 14:10:00
 * @Description:
 * @FilePath: \leetcode\1800-1899\1816\1816.js
 */
/**
 * @param {string} s
 * @param {number} k
 * @return {string}
 */
// var truncateSentence = function (s, k) {
//     const arr = s.split(' ');
//     arr.length = k;
//     return arr.join(' ');
// };
var truncateSentence = function (s, k) {
    return s.split(' ').slice(0, k).join(' ');
};
console.log(truncateSentence('chopper is not a tanuki', 4));
